using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace Sale_and_manage
{
    public partial class Login : DevComponents.DotNetBar.Metro.MetroForm
    {
        public Login()
        {
            InitializeComponent();
        }

        public int check = 0;

        public Boolean CheckLogin(string ID, string Pass)
        {
            if ((ID == "admin") && (Pass == "123"))
            {
                return true;
            }
            else
            {
                if ((ID == "abc") && (Pass == "123"))
                {
                    return true;
                }
                else
                return false;
            }
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (CheckLogin(txtID.Text, txtPass.Text))
            {
                check = 1;
                Mainform.UserID = txtID.Text;
                this.Close();
            }
            else
            {
                txtPass.Text = "";
                txtID.Text = "";
                MessageBox.Show("Invalid id or password. please try again!");
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            check = 1;
            Application.Exit();
        }

        private void Login_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (check == 0)
            {
                e.Cancel = true;
            }
        }

        protected override bool ProcessDialogKey(Keys keyData)
        {
            if (keyData == Keys.Enter)
                buttonX1_Click(null, null);
            return base.ProcessDialogKey(keyData);
        }

        
    }
}